package com.lastproject.web.bean;

import java.util.Date;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import com.lastproject.dto.UserDTO;
import com.lastproject.ejb.dao.UserDAORemote;

@ManagedBean
@SessionScoped
public class UserBean {

	private String username;
	private String password;
	private String statusPassword;
	private String firstname;
	private String lastname;
	private String workEmail;
	private Date dob;
	private String personalPhone;
	private String personalEmail;
	private Date employmentDate;
	private Date departureDate;
	private Date medCheckUpDate;
	private String employmentType;
	private String position;
	private byte[] cv;

	@ManagedProperty(value = "#{userDTO}")
	private UserDTO userDTO;

	@EJB
	UserDAORemote userDAORemote;

	public UserDTO getUserDTO() {
		return userDTO;
	}

	public void setUserDTO(UserDTO userDTO) {
		this.userDTO = userDTO;
	}

	public UserBean() {
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getWorkEmail() {
		return workEmail;
	}

	public void setWorkEmail(String workEmail) {
		this.workEmail = workEmail;
	}

	public Date getDob() {
		return dob;
	}

	public void setDob(Date dob) {
		this.dob = dob;
	}

	public String getPersonalPhone() {
		return personalPhone;
	}

	public void setPersonalPhone(String personalPhone) {
		this.personalPhone = personalPhone;
	}

	public String getPersonalEmail() {
		return personalEmail;
	}

	public void setPersonalEmail(String personalEmail) {
		this.personalEmail = personalEmail;
	}

	public Date getEmploymentDate() {
		return employmentDate;
	}

	public void setEmploymentDate(Date employmentDate) {
		this.employmentDate = employmentDate;
	}

	public Date getDepartureDate() {
		return departureDate;
	}

	public void setDepartureDate(Date departureDate) {
		this.departureDate = departureDate;
	}

	public Date getMedCheckUpDate() {
		return medCheckUpDate;
	}

	public void setMedCheckUpDate(Date medCheckUpDate) {
		this.medCheckUpDate = medCheckUpDate;
	}

	public String getEmploymentType() {
		return employmentType;
	}

	public void setEmploymentType(String employmentType) {
		this.employmentType = employmentType;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public byte[] getCv() {
		return cv;
	}

	public void setCv(byte[] cv) {
		this.cv = cv;
	}


	public void addUser() {

		UserDTO u = new UserDTO();

		u.setUsername(username);
		u.setPassword(password);
		u.setStatusPassword("newPassword"); // newPassword
		u.setFirstname(firstname);
		u.setLastname(lastname);
		u.setWorkEmail(workEmail);

		u.setDob(dob);
		u.setPersonalPhone(personalPhone);
		u.setPersonalEmail(personalEmail);
		u.setEmploymentDate(employmentDate);
		u.setDepartureDate(departureDate);
		u.setMedCheckUpDate(medCheckUpDate);
		u.setEmploymentType(employmentType);
		u.setPosition(position);
		// u.setCv(cv);


		userDAORemote.create(u);
		
		

		// EmployeeDTO e = new EmployeeDTO();

		// // private int prosisNr;
		// // private String workEmail;
		// // private String workPhone;
		// //
		// // private String germanContactPerson;
		// // private String careerLevel;
		// // private int id;
		//
		// e.setUsername(username);
		// e.setPassword(password);
		// e.setStatusPassword("newPassword"); //newPassword
		// e.setFirstname(firstname);
		// e.setLastname(lastname);
		// e.setWorkEmail(workEmail);
		// e.setDob(dob);
		// e.setPersonalPhone(personalPhone);
		// e.setPersonalEmail(personalEmail);
		// e.setEmploymentDate(employmentDate);
		// e.setDepartureDate(departureDate);
		// e.setMedCheckUpDate(medCheckUpDate);
		// e.setEmploymentType(employmentType);
		// e.setPosition(position);
		// //u.setCv(cv);
		//
		// employeeDAORemote.create(e);

	}

}
